import type { IResSpu, IResSpuList, SalesAttributes, SpuImageList } from '@/types/spu'
import { http } from '@/utils/request'
/**
 * @description 获取spu列表
 * @param page 当前页码
 * @param limit 每页展示数量
 */
export const reqSpuList = (page: number, limit: number, category3Id: number | string) => {
  return http<IResSpuList>(`/admin/product/${page}/${limit}?category3Id=${category3Id}`, 'GET')
}
/**
 * @description 获取spu详情
 * @param spuId spuId
 */
export const reqSpuDetails = (spuId: number) => {
  return http<IResSpu>(`/admin/product/getSpuById/${spuId}`, 'GET')
}
/**
 * @description 删除spu
 * @param spuId spuId
 */
export const reqDelSpu = (spuId: number) => {
  return http(`/admin/product/deleteSpu/${spuId}`, 'DELETE')
}
/**
 * @description 添加spu信息
 * @param data
 */
export const reqAddSpu = (data: IResSpu) => {
  return http('/admin/product/saveSpuInfo', 'POST', data)
}
/**
 * @description 编辑spu信息
 * @param data
 */
export const reqEditSpu = (data: IResSpu) => {
  return http('/admin/product/updateSpuInfo', 'POST', data)
}
/**
 * @description 获取销售属性列表信息
 */
export const reqSpuAttributeList = () => {
  return http<SalesAttributes[]>('/admin/product/baseSaleAttrList', 'GET')
}

/**
 * @description 获取spuId图片列表
 * @param spuId
 */
export const reqSpuImageList = (spuId: number) => {
  return http<SpuImageList[]>(`/admin/product/spuImageList/${spuId}`, 'GET')
}
